package com.diandi.messages.service.impl.template;

import com.diandi.messages.bean.template.MsgPassTemplate;
import com.diandi.messages.manager.template.MsgPassTemplateManager;
import com.diandi.messages.mapper.template.MsgPassTemplateMapper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by jiangquan1900 on 2017/10/29.
 */
@Component
public class MsgPassTemplateManagerImpl implements MsgPassTemplateManager {

    @Autowired
    private MsgPassTemplateMapper msgPassTemplateMapper;

    /**
     * 两个参数需同时存在
     * @param merchantNo 商户号
     * @param msgTemplateCode 模板号
     * @return
     */
    @Override
    public MsgPassTemplate querySingle(String merchantNo, String msgTemplateCode, Integer status) {
        if (StringUtils.isBlank(merchantNo) || StringUtils.isBlank(msgTemplateCode)){
            return null;
        }

        Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.put("merchantNo", merchantNo);
        paramMap.put("msgTemplateCode", msgTemplateCode);
        paramMap.put("status", status);

        return msgPassTemplateMapper.querySingle(paramMap);
    }
}
